
<%@page import="java.util.*,persistencia.*, modelo.*"contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859" />
    <title>TELA DESPESAS</title>
   
   <script languag="javascript">
/*/function criaXMLHttp() {
if (typeof XMLHttpRequest != "undefined")
return new XMLHttpRequest();
else if (window.ActiveXObject){
var versoes = ["MSXML2.XMLHttp.5.0",
"MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0",
"MSXML2.XMLHttp", "Microsoft.XMLHttp"
];
}
for (var i = 0; i < versoes.length; i++){
try{
return new ActiveXObject(versoes[i]);
}catch (e) {}
}
throw new Error("Seu browser nao suporta AJAX");
}


function recuperaCliente(campo) {

	var XMLHttp = criaXMLHttp();

	XMLHttp.open("get", "leCliente.jsp?cod=" + campo.value, true);


	XMLHttp.onreadystatechange = function () {
	if (XMLHttp.readyState == 4)
		if (XMLHttp.status == 200){
			document.getElementById("nome").value = XMLHttp.responseText;
		} else {
			document.getElementById("nome").value = "Um erro ocorreu" + XMLHttp.statusText;
		}

	};
	XMLHttp.send(null);



}    */    
        function recuperaSubCategorias(campo) {
       
	var XMLHttp = criaXMLHttp();

	XMLHttp.open("get", "recuperaSubCategorias.jsp?cod=" + campo.value, true);


	XMLHttp.onreadystatechange = function () {
	if (XMLHttp.readyState == 4)
		if (XMLHttp.status == 200){
			document.getElementById("nome").value = XMLHttp.responseText;
		} else {
			document.getElementById("nome").value = "Um erro ocorreu" + XMLHttp.statusText;
		}

	};
	XMLHttp.send(null);            
       
       
        }
            </script>
    <style type="text/css">
        <!--
        .style1 {
            font-family: Times New Roman, Times, serif;
            background:black;
            
            
        }
        .style2 {
            
            position:absolute;
            top: 170px;
            left:8px;
            background:black;
            
        }
        .style3{
            
            height:500px;
            background:#999999;
            
        }
        .body{
               
background-repeat:repeat;
	}
                
        .texto {
            font-family:verdana,arial;
            text-decoration: none; 
            color:white;
            font-size: 12px
        }
        .texto:hover {
            font-family:verdana,arial;
            text-decoration: underline; 
            color: orange; 
            font-size: 10px
        }
        a.dcontexto{
                font-family:verdana,arial;
                text-decoration: none; 
                color:white;
                font-size: 12px;
                position:relative; 
                padding:0;
                border-bottom:2px dotted #039;
                cursor:help; 
                z-index:24;
  }
            a.dcontexto:hover{
                background:transparent;
                z-index:25; 
                font-family:verdana,arial;
                text-decoration: underline; 
                color: orange; 
                font-size: 10px
  }
  a.dcontexto span{display: none}
  a.dcontexto:hover span{ 
  display:block;
  position:absolute;
  width:230px; 
  top:3em;
  text-align:justify;
  left:0;
  font: 12px arial, verdana, helvetica, sans-serif; 
  padding:5px 10px;
  border:1px solid #999;
  background:#e0ffff; 
  color:#000;
  }
        -->
</style></head>
 <body  class="body" background="imagemDeFundo.jpg">
<center> <font size="3" face="arial" > <h1>Gasto Zero</h1></font></center><br/><br/><br/>
            
            <div class="style1" >
                
                <center>
                    <font ><a href="Menu.jsp" class="texto" >MENU</a></font>&nbsp;&nbsp;&nbsp;&nbsp;
                    <font ><a href="Categorias.jsp" class="dcontexto" >CATEGORIA<span><strong>CATEGORIA</strong>
Categoria de Despesas </strong>.</span></a></font>&nbsp;&nbsp;&nbsp;&nbsp;
                <font ><a href="Subcategorias.jsp" class="dcontexto" >SUBCATEGORIAS<span><strong>SUBCATEGORIA</strong>
Sub-categoria de Despesas </strong>.</span></a></font>&nbsp;&nbsp;&nbsp;&nbsp;
                    <font  class="texto"><a class="texto"  href="TelaReceitas.jsp">RECEITAS</a></font>&nbsp;&nbsp;&nbsp;&nbsp;
                    <font class="texto" ><a class="texto"  href="Despesas.jsp">DESPESAS</a></font>&nbsp;&nbsp;&nbsp;&nbsp;
                    <font class="texto" ><a class="texto"  href="ListarDespRec.jsp">ORCAMENTO TOTAL</a></font>&nbsp;&nbsp;&nbsp;&nbsp;
                    <font  class="texto"><a class="texto"  href="Grafico.jsp" class="texto">GERAR GR&Aacute;FICO</a> </font>&nbsp;&nbsp;&nbsp;&nbsp;
                    <font  class="texto"><a class="texto"  href="GerarRelatorio.jsp" class="texto"> GERAR RELAT&Oacute;RIO</a></font> &nbsp;&nbsp;&nbsp;&nbsp;               
                                    <font  class="texto"><a class="texto"  href="index.jsp">SAIR >></a></font>&nbsp;&nbsp;&nbsp;&nbsp;
                    
                    
                </center>
            </div>
            <form action="">
            <div class="style3">
            <center>
                <h3>DESCRICAO DAS DESPESAS</h3>
                
        </center></br>
        
        <center>
            <%
                // tirar todo esse trecho e colocar em um servlet
                    CategoriaDAO categoriaDAO = new CategoriaDAO();
                    Vector cat =  categoriaDAO.getCategorias();
                    Iterator categorias = cat.iterator();
                    // no servlet isso será um request.setAttribute... 
                    pageContext.setAttribute("categorias", categorias);

                %>
            <h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Categoria:&nbsp;
           </h3>
           
           <select name="categoria" id="nome_categoria" onchange="recuperaSubCategorias(this);">
               <c:forEach var="categoria"   items="${categorias}">
            <option value="${categoria.id_categoria}">
                ${categoria} 
            </option>
          </c:forEach>
          <% /*
            Iterator it = categorias.iterator();
            while (it.hasNext()) {
                
                Categoria cat = (Categoria) it.next();
                out.println("<option value="+  cat.getId_categoria() + ">"+cat.getNome_categoria()+"</option>" );
                
                
            }
        */
        %>
            
        </select> </br>
         <%--
                    SubcategoriaDAO dao = new SubcategoriaDAO();
                    Vector subcategoria =  dao.getSubcategorias();
                --%>
    <h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Subcategoria: &nbsp;&nbsp; <select name="Subcategoria"></h3></br>
   
    <%--
            Iterator it = subcategoria.iterator();
            while (it.hasNext()) {
                
                Subcategoria sub = (Subcategoria) it.next();
                out.println("<option value="+  sub.getId_subcategoria()+ ">"+sub.getNome_subcategoria() +"</option>" );
                
                
            }
        
        --%>
   
    </select> 
    <h3>&nbsp;&nbsp;&nbsp;Mes:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select name="mes">
            <option>Janeiro</option>
            <option>Fevereiro</option>
            <option>Março</option>
            <option>Abril</option>
            <option>Maio</option>
            <option>Junho</option>
        </select></h3> 
        <h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ano:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="ano" value="" /></h3>
    
    <h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Descrição: <input type="text" name="descricao" value="" /></h3>
    <h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Data: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<input type="text" name="data" value="" /></h3>
    <h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Valor: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="valor" value="" /></h3>
    
    <input type="submit" value="Enviar" />
    <input type="reset" value="Limpar" />
    <a href="ListarDespesas.jsp"><input type="submit" value="Listar" /></a>
  </div>
  </center>
  </form>
  
 

</body>
</html>
